package LC08;

/**
 * 746. 使用最小花费爬楼梯
 */
public class LC0746 {
    public static void main(String[] args) {
        System.out.println(minCostClimbingStairs(new int[]{10, 15, 20}));
    }
    public static int minCostClimbingStairs(int[] cost) {
        int length = cost.length;
        int[] arr = new int[length + 1];
        arr[0] = arr[1] = 0;

        for (int i = 2; i < length + 1; i++) {
            arr[i] = Math.min(cost[i - 1] + arr[i - 1], cost[i - 2] + arr[i - 2]);
        }
        return arr[length];
    }
}
